﻿--[[
   @brief    run-game popup window
   @author   rudolfzhang
   @version  1.0
   @date     2015-03-27
--]]

ierd_tgp.tpf_ui.Require("popup_wnd\\view.lua");
ierd_tgp.tpf_ui.Require("web_bottom\\control.lua");

base_utility.log("loading popup_wnd model.lua");

popup_wnd_constants = {
    kPopupWidth = 480,
    kPopupHeight = 230
};

popup_wnd_model = {

    --icon_url = "ONEIMAGE:main\\default_icon.png;Stretch;0;";
    icon_url = "ONEIMAGE:client_tips\\def_square_img.png?155,11,205,61;Center;0;";
    player_uin;
    action_info;
    game_info_table = {};
    game_count = 0;
    kill_process_info = ierd_tgp.game_library.KillProcessInfo:new();
    op_from = 0;
    profile_game_id_ = 0; -- 云存档相关操作的game_id
    profile_action_returned_ = 0;

    tip_clicked = {};
    win2tip = {};

    wnd_minimize = {};
    already_show_tas_dangers = {};

    game_running_state = 0;
    winfo_num = 0;
    waiting_tips_info = {};

    init = function()
        comm_center.reg_service("i_service_check_should_show_poptips",
                                "popup_wnd_model.on_check_should_show_poptips");
        base_utility.log("popup_wnd model init success");
    end;

    tas_scandangers_param = {  
        position = "center",
        title = LoadStr("POP_WND_TAS_TITLE"),
        descTitle = LoadStr("POP_WND_TAS_DESCTITLE"),
        desc = LoadStr("POP_WND_TAS_DESC"),
        okBtn = {
            visible = "true",
            text = LoadStr("POP_WND_TAS_OK"),
            handle = popup_wnd_view.tas_scandangers_modpwd_clicked,
        },
        cancelBtn = {
            visible = "true",
            text = LoadStr("POP_WND_TAS_CANCEL"),
            handle = popup_wnd_view.tas_scandangers_exit_clicked,
        }
    };
        
    set_repair_guide_wnd = function(event_id, json_str)
    -- 设置“运行游戏-启动失败修复引导对话框”的布局数据
        local info = base_utility.json_to_table(json_str);
        local cf_game_id = 2;
        popup_wnd_model.set_game_icon(cf_game_id); 
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_REPAIR_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = poptips_icons.kError,
            descTitle = "",
            desc = LoadStr("POP_WND_REPAIR_DESC"),
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_REPAIR_OK"),
                handle = popup_wnd_view.repair_btn_clicked,
            },
            cancelBtn = {
                visible = "true",
                text = LoadStr("POP_WND_REPAIR_CANCEL"),
                handle = function()
                end,
            },
            game_id = info.game_id,
            error_code = info.error_code
       }
       ui_utility.show_tips(param);
    end;

    set_failed_to_start_wnd = function(event_id, json_str)
    -- 设置“运行游戏-启动失败”弹框的布局数据
        local info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(info.game_id);
        local error_msg = LoadStr("POP_WND_FAILSTART_DESC");
        
        if info.tips_content ~= nil then
            error_msg = error_msg .. "：" .. info.tips_content;
        end;
        local param = {
            position = "center",
            title = LoadStr("POP_WND_FAILSTART_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = poptips_icons.kError,
            descTitle = "",
            desc = error_msg,
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_FAILSTART_OK"),
                handle = popup_wnd_view.cancel_btn_clicked,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_FAILSTART_CANCEL"),
                handle = function()
                end,
            },
            game_id = info.game_id,
            error_code = info.error_code
        }
        ui_utility.show_tips(param);
    end;

    show_toolbox_warning_tips = function(event_id, json_str)
        -- 工具箱弹窗
        local info = base_utility.json_to_table(json_str);
        local tips_icon = '';
        if info.icon == 'warning' then
            tips_icon = poptips_icons.kWarning;
        elseif info.icon == 'info' then
            tips_icon = poptips_icons.kInfo;
        elseif info.icon == 'error' then
            tips_icon = poptips_icons.kError;
        elseif info.icon == 'success' then
            tips_icon = poptips_icons.kSuccess;
        end

        local title_defalut = LoadStr("POP_WND_TOOLBOX_TITLE");
        local param = {
            position = "center",
            title = ((info.title and info.title) or title_defalut),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = tips_icon,
            descTitle = info.text or "",
            desc = info.detail or "",
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_TOOLBOX_OK"),
                handle = popup_wnd_view.cancel_btn_clicked,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_TOOLBOX_CANCEL"),
                handle = function()
                end
            }
        }
        ui_utility.show_tips(param);
    end;

    
    set_anti_piracy_wnd = function(event_id, json_str)
    -- 设置“反盗版验证失败”弹框的布局数据
        local info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(info.game_id);
        local btn_text = LoadStr("POP_WND_ANTI_PIRACY_OK");
        if (info.btn_caption ~= nil) then
            btn_text = info.btn_caption;
        end;
        local need_show_repair = info.game_file_corrupted or false;
        local param = {
            position = "center",
            title = LoadStr("POP_WND_ANTI_PIRACY_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = poptips_icons.kError,
            descTitle = "",
            desc = info.tips_content,
            okBtn = {
                visible = "true",
                text = btn_text,
                handle = function()
                    if need_show_repair and info.game_id ~= nil then
                        -- 拉起游戏修复页面
                        comm_center.call_service("i_open_repair_game_wnd", {game_id=info.game_id});
                    elseif info.show_detail == 1  and info.game_id ~= nil then
                        local param = {};
                        param.type = "mmo_game";
                        param.sub_page = "GAME_DETAIL";
                        param.game_id = info.game_id;
                        web_utility.open_link(base_utility.table_to_json(param));
                    end;
                    popup_wnd_view:cancel_btn_clicked();
                end,
            },
            cancelBtn = {
                visible = need_show_repair and "true" or "false",
                text = LoadStr("POP_WND_ANTI_PIRACY_CANCEL"),
                handle = function()
                end,
            },
            game_id = info.game_id,
            error_code = info.error_code
        }
        ui_utility.show_tips(param);
    end;
    
    set_anti_tgp_need_update_wnd = function(event_id, json_str)
        local info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(info.game_id);
        local param = {
            position = "center",
            title = LoadStr("POP_WND_NEEDUPDATE_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = poptips_icons.kError,
            descTitle = "",
            desc = info.tips_content,
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_NEEDUPDATE_OK"),
                handle = function()
                    local gamelib =
                        base_utility.get_component_adapter("IGame_library",
                            "ierd_tgp.game_library.Get_game_library_adapter();");
                    if gamelib ~= nil then
                        gamelib:do_update_app();
                    end;
                    popup_wnd_view:cancel_btn_clicked();
                end,
            },
            cancelBtn = {
                visible = "true",
                text = LoadStr("POP_WND_NEEDUPDATE_CANCEL"),
                handle = function()
                end,
            }
        }
        ui_utility.show_tips(param);
    end;


    set_identity_verification_wnd = function(event_id, json_str)
    -- 设置“运行游戏-未实名认证”弹框的布局数据
        local info = base_utility.json_to_table(json_str);
        local current_uin = info.uin;
        local param = {
            position = "center",
            title = LoadStr("POP_WND_IDENTITY_VERIFICATION_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = "",
            descTitle = "",
            hyperLink = true,
            hyperLinkHandle = popup_wnd_view.identity_verification_btn_clicked,
            desc = LoadStr("POP_WND_IDENTITY_VERIFICATION_DESC_B") .. LoadStr("POP_WND_IDENTITY_VERIFICATION_DESC_E"),
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_IDENTITY_VERIFICATION_OK"),
                handle = popup_wnd_view.identity_verification_btn_clicked,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_IDENTITY_VERIFICATION_CANCEL"),
                handle = function()
                end
            }
        }
        ui_utility.show_tips(param);
    end;

    set_exit_game_wnd = function(id, json_str)
    -- 设置“运行游戏-结束游戏”弹框的布局数据
        popup_wnd_model.action_info = base_utility.json_to_table(json_str);
        local game_id = popup_wnd_model.action_info.game_id_;
        local desc_str = "";
        desc_str = LoadStr(ID_EXIT_GAME_TISP_CONTENT);
        
        popup_wnd_model.set_game_icon(game_id);

        local param = {
            position = "center",
            title = LoadStr(ID_EXIT_GAME_TISP_TITLE),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = "",
            desc = desc_str,
            okBtn = {
                visible = "true";
                text = LoadStr(ID_EXIT_GAME_TISP_CONFIRM),
                handle = popup_wnd_view.exit_game_btn_clicked,
            },
            cancelBtn = {
                visible = "true",
                text = LoadStr(ID_EXIT_GAME_TISP_CANCEL),
                handle = function()
                end,
            }
        }
        ui_utility.show_tips(param);
    end;
    
    set_preupdate_game_wnd = function(id, json_str)
    -- 设置“运行游戏-预更新”弹框的布局数据
        popup_wnd_model.action_info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(popup_wnd_model.action_info.game_id_);
        local param = {
            position = "center",
            title = LoadStr("POP_WND_PREUPDATE_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = "",
            desc = LoadStr("POP_WND_PREUPDATE_DESC"),
            okBtn = {
                visible = "true";
                text = LoadStr("POP_WND_PREUPDATE_OK"),
                handle = popup_wnd_view.preupdate_game_btn_clicked,
            },
            cancelBtn = {
                visible = "true",
                text = LoadStr("POP_WND_PREUPDATE_CANCEL"),
                handle = function()
                end,
            }
        }
        ui_utility.show_tips(param);
    end;

    set_nonage_wnd = function(event_id, json_str)
    -- 设置“运行游戏-未成年人禁止游戏”弹框的布局数据
        local param = {
            position = "center",
            title = LoadStr("POP_WND_NOAGE_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = "",
            descTitle = "",
            hyperLink = true,
            hyperLinkHandle = popup_wnd_view.identity_verification_btn_clicked,
            desc = LoadStr("POP_WND_NOAGE_DESC"),
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_NOAGE_OK"),
                handle = popup_wnd_view.identity_verification_btn_clicked,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_NOAGE_CANCEL"),
                handle = function()
                end
            }
        }
        ui_utility.show_tips(param);
    end;
 
     set_update_fail_gamerunning_wnd = function(event_id, json_str)
    -- 设置“运行游戏-关闭正在运行的进程继续更新”弹框的布局数据
        local info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(info.game_id);
        if info.op_from ~= nil then
            popup_wnd_model.op_from = info.op_from;
        end;
        popup_wnd_model.kill_process_info.game_id = info.game_id;
        popup_wnd_model.kill_process_info.server_id = info.server_id;
        popup_wnd_model.kill_process_info.uin = popup_wnd_model.player_uin;
        popup_wnd_model.kill_process_info.count = info.count;
        popup_wnd_model.kill_process_info.process_infos[0].path = info.process_info_0;
        popup_wnd_model.kill_process_info.process_infos[1].path = info.process_info_1;
        popup_wnd_model.kill_process_info.process_infos[2].path = info.process_info_2;
        popup_wnd_model.kill_process_info.process_infos[3].path = info.process_info_3;
        popup_wnd_model.kill_process_info.process_infos[4].path = info.process_info_4;
        -- log
        ierd_tgp.tpf_ui.Log("[popup wnd]game_id: "..popup_wnd_model.kill_process_info.game_id);
        ierd_tgp.tpf_ui.Log("[popup wnd]op_from: "..popup_wnd_model.op_from);
        ierd_tgp.tpf_ui.Log("[popup wnd]server_id: "..popup_wnd_model.kill_process_info.server_id);
        ierd_tgp.tpf_ui.Log("[popup wnd]player_uin: "..popup_wnd_model.kill_process_info.uin);
        ierd_tgp.tpf_ui.Log("[popup wnd]count: "..popup_wnd_model.kill_process_info.count);
        ierd_tgp.tpf_ui.Log("[popup wnd]info.process_info_0: "..popup_wnd_model.kill_process_info.process_infos[0].path);
        ierd_tgp.tpf_ui.Log("[popup wnd]info.process_info_1: "..popup_wnd_model.kill_process_info.process_infos[1].path);
        ierd_tgp.tpf_ui.Log("[popup wnd]info.process_info_2: "..popup_wnd_model.kill_process_info.process_infos[2].path);
        ierd_tgp.tpf_ui.Log("[popup wnd]info.process_info_3: "..popup_wnd_model.kill_process_info.process_infos[3].path);
        ierd_tgp.tpf_ui.Log("[popup wnd]info.process_info_4: "..popup_wnd_model.kill_process_info.process_infos[4].path);

        local param = {
            position = "center",
            title = LoadStr("POP_WND_UPDATEFAIL_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = "",
            desc = LoadStr("POP_WND_UPDATEFAIL_DESC"),
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_UPDATEFAIL_OK"),
                handle = popup_wnd_view.kill_update,
            },
            cancelBtn = {
                visible = "true",
                text = LoadStr("POP_WND_UPDATEFAIL_CANCEL"),
                handle = function()
                end,
            },
            game_id = info.game_id,
            error_code = info.error_code
        }
        ui_utility.show_tips(param);
    end;

    set_cloud_game_running_wnd = function(event_id, json_str)
        local info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(info.game_id);

        --local tips_content = LoadStr("CLOUD_GAME_ALREADY_RUNNING_TIPS");
        local game_name = "";
        local game_lib =
                base_utility.get_component_adapter("IGame_library",
                    "ierd_tgp.game_library.Get_game_library_adapter();");
        if game_lib ~= nil then
            local game_info = ierd_tgp.game_library.GameDetailInfo:new();
            game_lib:get_game_detail_info(info.game_id, game_info);
            game_name = game_info.name;
            game_info:delete();
        end;
        local desc = string.format(LoadStr("CLOUD_GAME_ALREADY_RUNNING_TIPS"), game_name);
        local param = {
            position = "center",
            title = LoadStr("POP_TIPS_TIPS"),
            width = 480,
            height = 230,
            titleIcon = "",
            icon = "",
            tipsIcon = popup_wnd_model.icon_url,
            descTitle = "",
            desc = desc,
            okBtn = {
                visible = "true",
                text = LoadStr("POP_TIPS_BTN_OK"),
                handle = popup_wnd_view.cancel_btn_clicked,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_TIPS_DEFAULT_CANCEL"),
                handle = function()
                end,
            },
            game_id = info.game_id,
        }
        ui_utility.show_tips(param);
    end;

    common_tips = function(data)
        base_utility.log("[popup_wnd_model][common_tips]start");
        if data == nil or data.tips_name == nil then
            base_utility.log("[popup_wnd_model][common_tips]data is empty");
            return;
        end;
        if data.tips_name == "downloaded_file_md5_error" then
            popup_wnd_model.set_game_icon(data.game_id);
            local game_lib =
                base_utility.get_component_adapter("IGame_library",
                    "ierd_tgp.game_library.Get_game_library_adapter();");
            local game_name = "";
            if game_lib ~= nil then
                local game_info = ierd_tgp.game_library.GameDetailInfo:new();
                game_lib:get_game_detail_info(data.game_id, game_info);
                game_name = game_info.name;
                game_info:delete();
            end;
            local desc_txt = game_name .. LoadStr("POP_WND_MD5FAILED_DESC");
            local download_file_check_md5_failed = {
                position = 'center',
                title = LoadStr("POP_WND_MD5FAILED_TITLE"),
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = poptips_icons.kError,
                descTitle = "",
                desc = desc_txt,
                modal = false,
                cancelBtn = {
                    visible = "false",
                    text = LoadStr("POP_WND_MD5FAILED_CANCEL"),
                    handle = function()
                        --[[
                        local game_id = data.game_id;
                        local game_lib =
                            base_utility.get_component_adapter("IGame_library",
                                "ierd_tgp.game_library.Get_game_library_adapter();");
                        game_lib:continue_download_game(game_id); -- 继续下载
                        if data.tips_data ~= nil then 
                            local tips_data = base_utility.json_to_table(data.tips_data);
                            if tips_data ~= nil and tips_data.task_id ~= nil then 
                                comm_center.call_service("Svr_HandleMd5CheckFailed",
                                    {game_id = game_id,
                                    task_id = tips_data.task_id,
                                    continue_download = 1});
                            end;
                        end;
                        popup_wnd_view.report_click_url(
                            ierd_tgp.adapt_for_imports.qos.Qos_url_click_type.kUrlTypeInstallerTipsOp,
                            game_id, 0);
                        ]]
                    end
                },
                okBtn = {
                    close_win = true,
                    visible = "true";
                    text = LoadStr("POP_WND_MD5FAILED_OK"),
                    handle = function()
                        local game_id = data.game_id;
                        local game_lib =
                            base_utility.get_component_adapter("IGame_library",
                                "ierd_tgp.game_library.Get_game_library_adapter();");
                        game_lib:cancel_download_game(game_id); -- 删除已下载文件
                        game_lib:download_game(game_id); -- 重新开始下载
                        if data.tips_data ~= nil then 
                            local tips_data = base_utility.json_to_table(data.tips_data);
                            if tips_data ~= nil and tips_data.task_id ~= nil then 
                                comm_center.call_service("Svr_HandleMd5CheckFailed",
                                    {game_id = game_id,
                                    task_id = tips_data.task_id,
                                    continue_download = 0});
                            end;
                        end;
                        popup_wnd_view.report_click_url(
                            ierd_tgp.adapt_for_imports.qos.Qos_url_click_type.kUrlTypeInstallerTipsOp,
                            game_id, 1);
                    end
                },
                game_id = data.game_id,
                error_code = data.error_code
            };
            ui_utility.show_tips(download_file_check_md5_failed);
        end;
        if data.tips_name == "game_locked_tips" then
            local param = {
                position = "center",
                title = LoadStr("POP_WND_GAMELOCK_TITLE"),
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = poptips_icons.kError,
                descTitle = LoadStr("POP_WND_GAMELOCK_DESC"),
                desc = data.tips_data,
                okBtn = {
                    visible = "true",
                    text = LoadStr("POP_WND_GAMELOCK_OK"),
                    handle = popup_wnd_view.cancel_btn_clicked,
                },
                cancelBtn = {
                    visible = "false",
                    text = LoadStr("POP_WND_GAMELOCK_CANCEL"),
                    handle = function()
                    end,
                },
                game_id = data.game_id,
                error_code = data.error_code
            }
        ui_utility.show_tips(param);
        end;
        if data.tips_name == "game_local_path_change_tips" then
            popup_wnd_model.set_game_icon(data.game_id);
            local title_desc = data.tips_data;       
            local limit_num = base_utility.cal_str_num_in_len(title_desc, 250);
            local desc_cui = U8toCUIStrn(title_desc, limit_num, 1);
            title_desc = CUIStrtoU8(desc_cui);
 
            local param = {
                position = "center",
                title = LoadStr("POP_WND_DIR_CHANGE"),
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                max_title_height = 110,
                titleIcon = "",
                icon = "",
                tipsIcon = popup_wnd_model.icon_url,
                descTitle = title_desc,
                desc = "",
                modal = false,
                is_multi_win = true,
                okBtn = {
                    visible = "true",
                    text = LoadStr("POP_WND_NETBAR_OK"),
                    close_win = true,
                    handle = function()
                    end,
                },
                cancelBtn = {
                    visible = "false",
                    text = LoadStr("POP_WND_NETBAR_CANCEL"),
                    handle = function()
                    end,
                },
                game_id = data.game_id,
                error_code = data.error_code
            }
            ui_utility.show_tips(param);
        end;
        if data.tips_name == "check_sys_driver_space_to_install_game" then
            local sys_driver_path= "";
            if data.tips_data ~= nil then 
                sys_driver_path = " "..data.tips_data.." ";
            end
            local desc_txt = LoadStr("GAME_INSTALLING_SYS_DISK_SPACE_NOT_ENOUGH_STR_1")..sys_driver_path
                ..LoadStr("GAME_INSTALLING_SYS_DISK_SPACE_NOT_ENOUGH_STR_2");
            local check_sys_driver_space_not_enough = {
                position = 'center',
                title = LoadStr("GAME_INSTALLING_SYS_DISK_WARNNING_TITLE"),
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = poptips_icons.kError,
                descTitle = "",
                desc = desc_txt,
                modal = false,
                cancelBtn = {
                    visible = "false",
                    text = LoadStr("GAME_INSTALLING_SYS_DISK_WARNNING_CANCEL"),
                    handle = function()
                    end
                },
                okBtn = {
                    close_win = true,
                    visible = "true";
                    text = LoadStr("GAME_INSTALLING_SYS_DISK_WARNNING_OK"),
                    handle = function()
                        
                    end
                },
                game_id = data.game_id,
                error_code = data.error_code
            };
            ui_utility.show_tips(check_sys_driver_space_not_enough);
        end;
        if data.tips_name == "disk_space_not_enough_by_tinysetup" then
            local driver_path= "";
            if data.tips_data ~= nil and data.tips_data ~= "" then 
                driver_path = data.tips_data;
            end
            local desc_txt = driver_path .." " .. LoadStr("SPACE_NOT_ENOUGH_STR");
            local disk_space_not_enough_by_tinysetup = {
                position = 'center',
                title = LoadStr("GAME_INSTALLING_SYS_DISK_WARNNING_TITLE"),
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = poptips_icons.kWarning,
                descTitle = "",
                desc = desc_txt,
                modal = false,
                cancelBtn = {
                    visible = "false",
                    text = LoadStr("GAME_INSTALLING_SYS_DISK_WARNNING_CANCEL"),
                    handle = function()
                    end
                },
                okBtn = {
                    close_win = true,
                    visible = "true";
                    text = LoadStr("GAME_INSTALLING_SYS_DISK_WARNNING_OK"),
                    handle = function()
                        
                    end
                },
                game_id = data.game_id,
                error_code = data.error_code
            };
            ui_utility.show_tips(disk_space_not_enough_by_tinysetup);
        end;
        if data.tips_name == "not_enough_disk_space_to_install" then
            local desc_txt= LoadStr("ID_INSUFFICIENT_DISK_SPACE");
            local package_size = "";
            local param = {};
            if data.tips_data ~= nil and data.tips_data ~= "" then 
                param = base_utility.json_to_table(data.tips_data);
                desc_txt = param.path .." " .. LoadStr("SPACE_NOT_ENOUGH_STR");
            end

            --[[
            local disk_space_not_enough_by_tinysetup = {
                position = 'center',
                title = LoadStr("GAME_INSTALLING_SYS_DISK_WARNNING_TITLE"),
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = poptips_icons.kWarning,
                descTitle = "",
                desc = desc_txt,
                modal = false,
                cancelBtn = {
                    visible = "true",
                    text = LoadStr("GAME_INSTALLING_SYS_DISK_WARNNING_OK"),
                    handle = function()
                    end
                },
                okBtn = {
                    close_win = true,
                    visible = "true",
                    text = LoadStr("GAME_INSTALLING_SWITCH_INSTALL_PATH"), --切换目录
                    handle = function()
                        local req_param = {};
                        req_param["game_id"] = data.game_id;
                        req_param["installed_size"] = param.installed_size;
                        req_param["purpose"] = 1;
                        req_param["install_path"] = param.install_path;
                        comm_center.call_service("i_service_tinysetup_open_game_install_path", 
                            req_param);
                    end
                },
                game_id = data.game_id,
                error_code = data.error_code
            };
            ui_utility.show_tips(disk_space_not_enough_by_tinysetup);
            --]]
            local new_path = "";
            local new_path_size = 0;
            local path_info = {};
            path_info = comm_center.call_service("i_svr_get_recommend_root_path", {});
            if path_info.root_path ~= nil or path_info.root_path ~= "" then
                new_path = path_info.root_path;
                new_path_size = path_info.disk_space;
            end;
            if new_path_size < tonumber(param["installed_size"]) then
                new_path = "";
            end;
            local req_param = {};
            req_param["game_id"] = data.game_id;
            req_param["game_path"] = param.path;
            req_param["installed_size"] = param.installed_size;
            req_param["install_path"] = new_path;
            comm_center.call_service("i_service_tinysetup_open_game_install_path", 
                req_param);
               
        end;
        if data.tips_name == "download_path_driver_invalid" then
            local desc_txt= LoadStr("DOWNLOAD_PATH_DRIVER_INVALID_STR");
            local param = {};
            if data.tips_data ~= nil and data.tips_data ~= "" then 
                param = base_utility.json_to_table(data.tips_data);
                desc_txt = param.path .." " .. LoadStr("DOWNLOAD_PATH_DRIVER_INVALID_STR");
            end

            local download_path_driver_invalid = {
                position = 'center',
                title = LoadStr("POP_TIPS_TIPS"),
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = poptips_icons.kWarning,
                descTitle = "",
                desc = desc_txt,
                modal = false,
                cancelBtn = {
                    visible = "true",
                    text = LoadStr("POP_TIPS_BTN_OK"),
                    handle = function()
                    end
                },
                okBtn = {
                    close_win = true,
                    visible = "true",
                    text = LoadStr("GAME_INSTALLING_SWITCH_INSTALL_PATH"), --切换目录
                    handle = function()
                        local req_param = {};
                        req_param["game_id"] = data.game_id;
                        req_param["installed_size"] = param.installed_size;
                        req_param["purpose"] = 1;
                        req_param["install_path"] = param.install_path;
                        comm_center.call_service("i_service_tinysetup_open_game_install_path", 
                            req_param);
                    end
                },
                game_id = data.game_id,
                error_code = data.error_code
            };
            ui_utility.show_tips(download_path_driver_invalid);
        end;
        if data.tips_name == "tinysetup_common_tips" then
            -- tinysetup组件弹窗通用接口
            local tinysetup_tips_data = nil;
            if data.tips_data ~= nil and data.tips_data ~= "" then 
                tinysetup_tips_data = base_utility.json_to_table(data.tips_data);
            end
            if tinysetup_tips_data == nil then
                return;
            end
            local tips_icon = poptips_icons.kWarning;
            if nil ~= data.game_id and 0 ~= data.game_id then
                popup_wnd_model.set_game_icon(data.game_id);
                tips_icon = popup_wnd_model.icon_url;
            end
            local desc_txt = tinysetup_tips_data.desc_txt;
            local title_txt = tinysetup_tips_data.title_txt;
            
            local cancel_btn_txt = tinysetup_tips_data.cancel_btn_txt;
            local cancel_btn_show = tinysetup_tips_data.cancel_btn_show;
            local cancel_callback = tinysetup_tips_data.cancel_callback;
            
            local ok_btn_txt = tinysetup_tips_data.ok_btn_txt;
            local ok_btn_show = tinysetup_tips_data.ok_btn_show;
            local ok_callback = tinysetup_tips_data.ok_callback;

            if title_txt == nil or title_txt == "" then
                title_txt = LoadStr("POP_TIPS_TIPS");
            end;

            if cancel_btn_txt == nil or cancel_btn_txt == "" then
                cancel_btn_txt = LoadStr("POP_TIPS_CANCEL");
            end;
            if cancel_btn_show == nil or cancel_btn_show == "" then
                cancel_btn_show = "false";
            end;

            if ok_btn_txt == nil or ok_btn_txt == "" then
                ok_btn_txt = LoadStr("POP_TIPS_BTN_OK");
            end;
            if ok_btn_show == nil or ok_btn_show == "" then
                ok_btn_show = "false";
            end;

            local tinysetup_common_tips_param = {
                position = 'center',
                title = title_txt,
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = tips_icon,
                descTitle = "",
                desc = desc_txt,
                modal = false,
                cancelBtn = {
                    visible = cancel_btn_show,
                    text = cancel_btn_txt,
                    handle = function()
                        if cancel_callback ~= nil and cancel_callback ~= "" then
                            local callback_data = tinysetup_tips_data.cancel_callback_data or "";
                            local param = base_utility.json_to_table(callback_data) or {};
                            param.game_id = param.game_id or data.game_id;
                            param.error_code = param.error_code or data.error_code;
                            param.extra_info = param.extra_info or tinysetup_tips_data.extra_info;
                            comm_center.send_broadcast(cancel_callback, param);
                        end;
                    end
                },
                okBtn = {
                    close_win = true,
                    visible = ok_btn_show;
                    text = ok_btn_txt,
                    handle = function()
                        if ok_callback ~= nil and ok_callback ~= "" then
                            local callback_data = tinysetup_tips_data.ok_callback_data or "";
                            local param = base_utility.json_to_table(callback_data) or {};
                            param.game_id = param.game_id or data.game_id;
                            param.error_code = param.error_code or data.error_code;
                            param.extra_info = param.extra_info or tinysetup_tips_data.extra_info;
                            comm_center.send_broadcast(ok_callback, param);
                        end;
                    end
                },
                game_id = data.game_id,
                error_code = data.error_code
            };
            if tinysetup_tips_data.pre_service ~= nil and tinysetup_tips_data.pre_service ~= "" then
                local service_data = tinysetup_tips_data.pre_service_data or "";
                local service_obj = base_utility.json_to_table(service_data) or {};
                comm_center.call_service(tinysetup_tips_data.pre_service, service_obj);
            end
            ui_utility.show_tips(tinysetup_common_tips_param);
            if tinysetup_tips_data.post_service ~= nil and tinysetup_tips_data.post_service ~= "" then
                local service_data = tinysetup_tips_data.post_service_data or "";
                local service_obj = base_utility.json_to_table(service_data) or {};
                comm_center.call_service(tinysetup_tips_data.post_service, service_obj);
            end
        end;
        
        if data.tips_name == "login_tips_when_account_locked" then
        ierd_tgp.tpf_ui.Log("[popup wnd]login_tips_when_account_locked start ");
            -- 登陆时帐号被销定弹窗
            local login_tips_locked_data = nil;
            if data.tips_data ~= nil and data.tips_data ~= "" then 
                login_tips_locked_data = base_utility.json_to_table(data.tips_data);
            end
            if login_tips_locked_data == nil then
                return;
            end
            local desc_txt = LoadStr("STR_LOGIN_OFFSITE_LOGIN_ACCOUNT_UNDER_LOCKED_CONTINUE_LOGIN_DES");
            local title_txt = login_tips_locked_data.title_txt;
            
            local cancel_btn_txt = login_tips_locked_data.cancel_btn_txt;
            local cancel_btn_show = "true";--tinysetup_tips_data.cancel_btn_show;
            local cancel_callback = login_tips_locked_data.cancel_callback;
            
            local ok_btn_txt = login_tips_locked_data.ok_btn_txt;
            local ok_btn_show = "true";--tinysetup_tips_data.ok_btn_show;
            local ok_callback = login_tips_locked_data.ok_callback;
            
            local days_left = "";
            if login_tips_locked_data.days_left ~= nil then
                days_left = login_tips_locked_data.days_left;
            end;

            if title_txt == nil or title_txt == "" then
                title_txt = LoadStr("POP_TIPS_TIPS");
            end;

            if cancel_btn_txt == nil or cancel_btn_txt == "" then
                cancel_btn_txt = LoadStr("POP_TIPS_CANCEL");
            end;
            if cancel_btn_show == nil or cancel_btn_show == "" then
                cancel_btn_show = "false";
            end;

            if ok_btn_txt == nil or ok_btn_txt == "" then
                ok_btn_txt = LoadStr("STR_LOGIN_OFFSITE_LOGIN_ACCOUNT_UNDER_LOCKED_CONTINUE_LOGIN");
            end;
            if ok_btn_show == nil or ok_btn_show == "" then
                ok_btn_show = "false";
            end;
            
            local desc_txt_text = string.format(desc_txt, days_left);
            ierd_tgp.tpf_ui.Log("[popup wnd]login_tips_when_account_locked: "..desc_txt_text);
            local login_locked_common_tips_param = {
                position = 'center',
                title = title_txt,
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = poptips_icons.kWarning,
                descTitle = "",
                desc = desc_txt_text,
                modal = true,
                hyperLink = true,
                cancelBtn = {
                    visible = cancel_btn_show,
                    text = cancel_btn_txt,
                    handle = function()
                        if cancel_callback ~= nil and cancel_callback ~= "" then
                            local callback_data = login_tips_locked_data.cancel_callback_data or "";
                            local param = base_utility.json_to_table(callback_data) or {};
                            param.is_relogin = false;
                            comm_center.send_broadcast(cancel_callback, param);
                        end;
                    end
                },
                okBtn = {
                    close_win = true,
                    visible = ok_btn_show;
                    text = ok_btn_txt,
                    handle = function()
                        if ok_callback ~= nil and ok_callback ~= "" then
                             local callback_data = login_tips_locked_data.cancel_callback_data or "";
                            local param = base_utility.json_to_table(callback_data) or {};
                            param.is_relogin = true;
                            comm_center.send_broadcast(ok_callback, param);
                        end;
                    end
                },
                game_id = data.game_id,
                error_code = data.error_code
            };
           
            ui_utility.show_tips(login_locked_common_tips_param);
        end;
        
        if data.tips_name == "game_component_install_failed" then
            local show_txt= LoadStr("GAME_CHECK_COMMPONENT_ERROR_TIPS");
            if data.tips_data ~= nil and data.tips_data ~= "" then 
                show_txt = data.tips_data;
            end
            local desc_txt = show_txt;

            local game_component_install_failed_param = {
                position = 'center',
                title = LoadStr("POP_TIPS_TIPS"),
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                titleIcon = "",
                icon = "",
                tipsIcon = poptips_icons.kError,
                descTitle = "",
                desc = desc_txt,
                modal = false,
                cancelBtn = {
                    visible = "true",
                    text = LoadStr("POP_TIPS_CANCEL"),
                    handle = function()
                    end
                },
                okBtn = {
                    close_win = true,
                    visible = "true";
                    text = LoadStr("GAME_CHECK_COMMPONENT_ERROR_OPEN_FOLDER"),
                    handle = function()
                        local brd_data = {};
                        brd_data.game_id = data.game_id;
                        comm_center.send_broadcast("i_broadcast_open_dx2010_setup_path", brd_data);
                    end
                },
                game_id = data.game_id,
                error_code = data.error_code
            };
            ui_utility.show_tips(game_component_install_failed_param);
        end;
        if data.tips_name == "common_tips" then
            if data.tips_data ~= nil and data.tips_data ~= "" then 
                local tips_param = base_utility.json_to_table(data.tips_data);
                ui_utility.show_tips(tips_param);
            end;
        end;
        -- 可自动处理'不再提醒'勾选框，需提供'tips_hash'字段供区分是否需要显示当前tips
        if data.tips_name == "common_tips_v2" then
            -- 参数处理
            local tips_data = base_utility.json_to_table(data.tips_data);
            if nil == tips_data then return end;

            local tips_icon = "";
            if nil ~= tips_data.game_id and tips_data.use_game_icon ~= nil 
                and tips_data.use_game_icon == true then
                popup_wnd_model.set_game_icon(tips_data.game_id);
                tips_icon = popup_wnd_model.icon_url;
            end

            local defaultTipsData = {
                position = 'center',
                width = popup_wnd_constants.kPopupWidth,
                height = popup_wnd_constants.kPopupHeight,
                modal = false,
                tipsIcon = tips_icon,
                descTitle = "",
                is_multi_win = true,
                okBtn = {
                    visible = false
                },
                cancelBtn = {
                    visible = true,
                    text = LoadStr("TPF_CLOSE")
                },
            };

            -- 覆盖默认参数
            for k, v in pairs(tips_data) do
                defaultTipsData[k] = v;
            end;

            if nil == defaultTipsData.user_data then
                defaultTipsData.user_data = {};
            end

            -- '不再提醒'勾选框
            if nil ~= defaultTipsData.cbx_dont_ask and 
                true == defaultTipsData.cbx_dont_ask.visible then
                   
                   if nil ~= defaultTipsData.tips_hash then
                       if not popup_wnd_model.check_tips_need_show(data.tips_name,
                                                                    defaultTipsData.tips_hash) then
                            base_utility.log("[popup_wnd_model]cloud_game_tips do not need show");
                            return;
                        end
                   end

                   if nil == defaultTipsData.cbx_dont_ask.text then
                        defaultTipsData.cbx_dont_ask.text = LoadStr("TPF_POPTIPS_NO_WARNING");
                   end
                   
                   defaultTipsData.user_data.tipsName = data.tips_name;
                   defaultTipsData.user_data.tipsHash = defaultTipsData.tips_hash;

                   defaultTipsData.dontaskCallback = function(win_id, user_data, addon_info)
                        if nil ~= user_data and nil ~= addon_info and 
                            true == addon_info.cbx_dont_ask_checked then
                                popup_wnd_model.set_tips_user_disabled(user_data.tipsName,
                                                                        user_data.tipsHash);
                        end
                   end;
            end;

            -- 提示内容
            if nil ~= tips_data.hyperLinkText and "" ~= tips_data.hyperLinkText then
                defaultTipsData.hyperLink = true;
                local content_text = tips_data.desc or "";
                if string.find(content_text, "%%LinkText%%") == nil then
                    content_text = content_text .. " %LinkText%";
                end
                defaultTipsData.desc = content_text;
            end;

            -- 超链接
            if true == defaultTipsData.hyperLink then
                defaultTipsData.user_data.url = defaultTipsData.hyperLinkURL;
                defaultTipsData.user_data.open_link_close_wnd = 
                    defaultTipsData.open_link_close_wnd;
                defaultTipsData.hyperLinkHandle = function(uilib, ctrl_id, user_data, addon_info)
                    if nil ~= user_data and nil ~= user_data.url then
                        web_utility.open_link(user_data.url);
                        if user_data.open_link_close_wnd ~= nil 
                            and user_data.open_link_close_wnd == true then
                            popup_wnd_view.cancel_btn_clicked();
                        end;
                    end;
                end;
            end

            -- okBtn支持超链接
            if nil ~= defaultTipsData.okBtn then
                if nil ~= defaultTipsData.okBtn.hyperLinkURL then
                    local closure = function(url)
                        local ok_url = url;
                        local function inner_func(uilib, ctrl_id)
                            if nil ~= ok_url then
                                web_utility.open_link(ok_url);
                                popup_wnd_view.cancel_btn_clicked();
                            end;
                        end
                        return inner_func;
                    end;
                    defaultTipsData.okBtn.handle = closure(defaultTipsData.okBtn.hyperLinkURL);
                end;
            end
            ui_utility.show_tips(defaultTipsData);
        end;
    end;

    --  only for wall paper need update
    set_wallpaper_need_update_pop = function(event_id, json_str)
        local info = base_utility.json_to_table(json_str);
        local game_id = tonumber(info.game_id);
        local error_code = tonumber(info.error_code);
        popup_wnd_model.set_game_icon(info.game_id);
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_COMMON_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = info.tips_content,
            descRichTitle = info.rich_tips_content,
            desc = "",
            okBtn = {
                visible = "true",
                text = LoadStr("ID_TPF_GO_TO_UPDATE_GAME"),
                close_win = true,
                handle = function()
                    comm_center.call_service("SvrLua_Banner_GoToGame", {game_id = info.game_id});
                    web_bottom_control.update_game(info.game_id, 0);
                end,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_COMMON_CANCEL"),
                handle = function()
                end,
            },
            game_id = info.game_id,
            error_code = info.error_code
       }
       ui_utility.show_tips(param);
    end;

    set_common_wnd = function(event_id, json_str)
    -- 设置“通用弹框”的布局数据
    -- 包括“升级游戏杀掉进程”、“网吧游戏未安装”和“未满18周岁”等
        local info = base_utility.json_to_table(json_str);
        if nil ~= info then
            local game_id = tonumber(info.game_id);
            local error_code = tonumber(info.error_code);
            if game_id == 2001068 then
                if error_code == 3512001 or error_code == 7501018 then
                    popup_wnd_model.set_wallpaper_need_update_pop(event_id, json_str);
                    return;
                end;
            end;
        end;
        popup_wnd_model.set_game_icon(info.game_id);
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_COMMON_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = info.tips_content,
            descRichTitle = info.rich_tips_content,
            desc = "",
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_COMMON_OK"),
                close_win = true,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_COMMON_CANCEL"),
                handle = function()
                end,
            },
            game_id = info.game_id,
            error_code = info.error_code
       }
       ui_utility.show_tips(param);
    end;

    show_invalid_branch_tips = function(event_id, json_str)
        local info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(info.game_id);
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_COMMON_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = info.tips_content,
            desc = "",
            okBtn = {
                close_win = true,
                visible = "true",
                text = LoadStr("POP_TIPS_SWITCH_BRANCH"),
                handle = function()
                    local event_data = {};
                    event_data["game_id"] = info.game_id;
                    event_data["sub_page"] = "tab_branch";
                    event_center.send_event(frame_bottom_event.RAIL_PROPERTIES_BTN_CLICK_EVENT, 
                                            base_utility.table_to_json(event_data));
                end,
            },
            cancelBtn = {
                visible = "true",
                text = LoadStr("POP_WND_COMMON_OK"),
                handle = function()
                end,
            },
            game_id = info.game_id,
            error_code = info.error_code
       }
       ui_utility.show_tips(param);
    end;

    restart_tgp_tips = function(event_id, json_str)
    -- 启动游戏，换票据失败，重启TGP弹框
        local info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(info.game_id);
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_RESTART_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = "",
            desc = LoadStr("POP_WND_RESTART_DESC"),
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_RESTART_OK"),
                handle = popup_wnd_view.restart_tgp,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_RESTART_CANCEL"),
                handle = function()
                end,
            },
            game_id = info.game_id,
            error_code = info.error_code
       }
       ui_utility.show_tips(param);
    end;
    
    ShowOMDInstallWarning = function(event_id, json_str)
        popup_wnd_model.set_game_icon(201);
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_OMDINSTALL_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = "",
            desc = LoadStr("POP_WND_OMDINSTALL_DESC"),
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_OMDINSTALL_OK"),
                handle = popup_wnd_view.OnOMDInstallWarningOkClicked
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_OMDINSTALL_CANCEL"),
                handle = popup_wnd_view.OnOMDInstallWarningCancelClicked
            }
       }
       ui_utility.show_tips(param);
    end;

    show_netbar_order_tips = function(event_id, json_param)
        ierd_tgp.tpf_ui.Log("show_netbar_order_tips");
        local decode_str = popup_wnd_model.decode_str(json_param);
        ierd_tgp.tpf_ui.Log("show_netbar_order_tips, tips: "..decode_str);
        local temp = base_utility.json_to_table(decode_str);
        local param = {
            position = "rbottom",
            title = LoadStr("POP_WND_NETBAR_TITLE"),
            width = 280,
            height = 230,
            titleIcon = "",
            icon = "",
            tipsIcon = "",
            descTitle = temp.title,
            desc = temp.text,
            modal = false,
            cancelBtn = {
                visible = false,
                text = LoadStr("POP_WND_NETBAR_CANCEL"),
                handle = function()
                end
            },
            okBtn = {
                visible = false;
                text = LoadStr("POP_WND_NETBAR_OK"),
                handle = popup_wnd_view.cancel_btn_clicked
            }
        }
        ui_utility.show_tips(param);
    end;

    show_wegame_qualify_login_tips = function(event_id, json_str)
        local info = base_utility.json_to_table(json_str);
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_QUALIFY_LOGIN_TITLE"),
            width = 400,
            height = 200,
            titleIcon = "",
            icon = "",
            tipsIcon = "",
            descTitle = "",
            desc = info.desc,
            modal = false,
            manuallyCloseCallback = function()
                popup_wnd_view.wegame_qualify_login_tips_close(false);
            end,
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_QUALIFY_LOGIN_OK"),
                handle = function()
                    popup_wnd_view.wegame_qualify_login_tips_close(true, info.link);
                end,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_QUALIFY_LOGIN_CANCEL"),
                handle = function()
                end,
            }
       }

       ui_utility.show_tips(param);
    end;

    show_load_matrix_fail_tips = function(event_id, json_param)
        ierd_tgp.tpf_ui.Log("show_load_matrix_fail_tips");
        local decode_str = popup_wnd_model.decode_str(json_param);
        ierd_tgp.tpf_ui.Log("show_load_matrix_fail_tips, tips: "..decode_str);
        local info = base_utility.json_to_table(decode_str);
        
        info.position = 'rbottom';
        info.height = 188;
        info.width = 401;
        info.modal = false;
        info.is_multi_win = false;
        info.manuallyCloseCallback = function(win_id)
            local login_mgr =
                base_utility.get_component_adapter("ILogin_mgr",
                    "ierd_tgp.login_mgr.GetLoginMgr();");
            if login_mgr ~= nil then
                login_mgr:ClickLoadMatrixFail(false);
            end
        end;

        info.ui_file = "matrix_load_error.tpf";

        info.layout_callback = "popup_wnd_view.matrix_reload_error_layout";
        info.layout_file = "popup_wnd\\view.lua";

        base_utility.log("[popup_wnd_control] show matrix load fail window.");
        return ui_utility.show_tips(info);
    end;

    set_game_icon = function(game_id)
        local count = popup_wnd_model.game_count;
        local bFind = false;

        -- 显示主游戏icon
        local param = {};
        param["game_id"] = game_id;
        local result = comm_center.call_service("Svr_CheckIsSubInAttachRel", param);
        if (nil ~= result and nil ~= result.is_sub and 1 == result.is_sub and nil ~= result.main_game_id) then
            game_id = result.main_game_id;
        end
        if popup_wnd_model.game_info_table ~= nil then
            for key, value in pairs(popup_wnd_model.game_info_table) do
                if popup_wnd_model.game_info_table[key].game_id == game_id then
                    bFind = true;
                    local url = popup_wnd_model.game_info_table[key].game_info.banner_icon_url;
                    popup_wnd_model.icon_url = "ONEIMAGE:client_tips\\def_square_img.png|" .. url .. ";Stretch;0;";
                    break;
                end;
            end;
        end;
        -- 没有找到，尝试请求离线模式的服务
        if (not bFind) then
            local   zParam = {};
            
            zParam["GameID"] = game_id;

            local   zIcon = comm_center.call_service("Svr_GetGameIcon", zParam);

            if (0 ~= zIcon) and (nil ~= zIcon) and (nil ~= zIcon["icon"]) and 
                ("" ~= zIcon["icon"]) then
                popup_wnd_model.icon_url = "ONEIMAGE:client_tips\\def_square_img.png|" .. 
                                            zIcon["icon"] .. ";Stretch;0;";
            end;
        end;

        ierd_tgp.tpf_ui.Log("[popup wnd]popup_wnd_model.icon_url: "..popup_wnd_model.icon_url);
    end;

    set_icon_url = function(sIcon)
        if nil ~= sIcon and "" ~= sIcon then
            popup_wnd_model.icon_url = "ONEIMAGE:client_tips\\def_square_img.png|" .. sIcon .. ";Stretch;0;";
        else
            popup_wnd_model.icon_url = "ONEIMAGE:client_tips\\def_square_img.png;Stretch;0;";
        end;
    end;

    set_game_info = function(order, game_id, base_info, count)
        -- 当刷新游戏列表信息的时候，只有添加游戏才刷新列表信息，否则不变
        -- 【Reason】因为隐藏游戏的时候，游戏列表刷新后才弹出提示框，导致总是获取不到该游戏的Icon
        if count >= popup_wnd_model.game_count then
            popup_wnd_model.game_info_table[order] = {game_id, game_info};
            popup_wnd_model.game_info_table[order].game_id = game_id;
            popup_wnd_model.game_info_table[order].game_info = base_info;
            popup_wnd_model.game_count = count;
        end;
    end;

    -- 查询游戏权限失败，提示用户
    show_query_game_info_failed_wnd = function(info)
        local error_msg = '';
        if info.error_msg ~= nil and info.error_msg ~= '' then
            error_msg = info.error_msg..'('..LoadStr("TPF_ERROR_CODE")..info.error_code..')';
        else 
            error_msg = LoadStr("POP_WND_QUERYGAMEFAILED_DESC")..info.error_code;
        end;
        local tips_icon = "";
        if info.tips_icon ~= nil then
            tips_icon =info.tips_icon;
        end;
        local param = {
            position = "center",
            title = LoadStr("POP_WND_QUERYGAMEFAILED_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = tips_icon,
            descTitle = "",
            desc = error_msg,
            okBtn = {
                visible = false,
                text = LoadStr("POP_WND_QUERYGAMEFAILED_OK"),
                handle = function()
                end,
            },
            cancelBtn = {
                visible = true,
                text = LoadStr("POP_WND_QUERYGAMEFAILED_CANCEL"),
                handle = function()
                end,
            }
        }
        ui_utility.show_tips(param);
    end;

    -- 查询游戏权限失败，提示用户(fortnite专用，产品需要可配置提示内容)
    show_query_game_info_failed_wnd_2nd = function(info)
        local tips_icon = "";
        if info.tips_icon ~= nil then
            tips_icon =info.tips_icon;
        end;
        local param = {
            position = "center",
            title = LoadStr("POP_WND_NETBAR_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = tips_icon,
            descTitle = info.error_msg,
            descRichTitle = info.rich_error_msg,
            desc = "",
            okBtn = {
                visible = false,
                text = LoadStr("POP_WND_QUERYGAMEFAILED_OK"),
                handle = function()
                end,
            },
            cancelBtn = {
                visible = true,
                text = LoadStr("POP_WND_QUERYGAMEFAILED_CANCEL"),
                handle = function()
                end,
            }
        }
        ui_utility.show_tips(param);
    end;

    -- 提示切换离线
    show_switch_offline_mode_wnd = function(info)
        local tips_icon = "";
        if info.tips_icon ~= nil then
            tips_icon =info.tips_icon;
        end;
        local param = {
            position = "center",
            title = LoadStr("POP_WND_SWITCHOFFLINE_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = tips_icon,
            descTitle = "",
            desc = LoadStr("POP_WND_SWITCHOFFLINE_DESC"),
            okBtn = {
                visible = true,
                text = LoadStr("POP_WND_SWITCHOFFLINE_OK"),
                handle = function()
                    local param = {};
                    param["account_id"] = login_model.main_tgp_id;
                    local json_str = base_utility.table_to_json(param);
                    event_center.send_event(main_menue_event.MAIN_MENUE_SITCH_OFFLINE, json_str);
                end,
            },
            cancelBtn = {
                visible = true,
                text = LoadStr("POP_WND_SWITCHOFFLINE_CANCEL"),
                handle = function()
                end,
            }
        }
        ui_utility.show_tips(param);
    end;

    show_game_refunding_state_wnd = function(info)

        local link_text = '<a c="0xff9500" hc="0xff9500">'..LoadStr("POP_WND_REFUNDING_OK")..'</a>';
        local tips_icon = "";
        if info.tips_icon ~= nil then
            tips_icon =info.tips_icon;
        end;
        local param = {
            position = "center",
            title = LoadStr("POP_WND_REFUNDING_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = tips_icon,
            descTitle = "",
            desc = info.desc,
            okBtn = {
                close_win = true,
                visible = true,
                text = info.button_text,
                handle = function()
                    info.onOk();
                end,
            },
            cancelBtn = {
                visible = false,
                text = "",
                handle = function()
                    info.onCancel();
                end,
            },
            link_goto = {
                visible = true;
                text = link_text;
                link = '{"type":"my_assets","sub_nav":"game-purchase"}';
            }
        }
        ui_utility.show_tips(param);
    end;
    
    -- 内测游戏下载提示
    show_operate_state_wnd = function()
        local ok_txt = LoadStr("POP_WND_OPERATESTATE_OK");
        local tip_desc = LoadStr("POP_WND_OPERATESTATE_DESC");
        local param = {
            position = 'center',
            title = LoadStr("POP_WND_OPERATESTATE_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = "",
            descTitle = "",
            desc = tip_desc,
            modal = false,
            always_center = true,
            okBtn = {
                visible = true,
                close_win = true,
                text = ok_txt,
                handle = function()
                end,
            },
            cancelBtn = {
            visible = false,
            text = LoadStr("POP_WND_OPERATESTATE_CANCEL"),
            handle = function()
            end,
            }
        }
        ui_utility.show_tips(param);
    end;

    get_lowspeed_param = function(user_data, desc, btn_ok_text, btn_ok_handler, btn_cancel_text, btn_cancel_handler)
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_LOWSPEED_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            icon = "",
            tipsIcon = poptips_icons.kInfo,
            descTitle = LoadStr("POP_WND_LOWSPEED_DESC"),
            desc = desc,
            user_data = user_data,         
            cbx_dont_ask = {
                visible = true;
                text = LoadStr("POP_WND_LOWSPEED_ASK");
                checked = false;
            },
            okBtn = {
                visible = "true",
                text = btn_ok_text,
                handle = btn_ok_handler,
                close_win = true
            },
            cancelBtn = {
                visible = "true",
                text = btn_cancel_text,
                handle = btn_cancel_handler
            },
            close_means_cancel = false,
       }
        return param;
    end;
    
    get_lowspeed_param_pause = function(user_data)
        local desc = LoadStr("POP_WND_LOWSPEED_PAUSE_DESC");
        return popup_wnd_model.get_lowspeed_param(user_data, desc,
                    LoadStr("POP_WND_LOWSPEED_PAUSE_DONE"), popup_wnd_view.btn_enter_low_speed_clicked, LoadStr("POP_WND_LOWSPEED_PAUSE_CANCEL"), popup_wnd_view.btn_pause_preudpate_clicked);
    end;
    
    get_lowspeed_param_exit = function(user_data)
        local desc = LoadStr("POP_WND_LOWSPEED_EXIT_DESC");
        return popup_wnd_model.get_lowspeed_param(user_data, desc,
                    LoadStr("POP_WND_LOWSPEED_EXIT_DONE"), popup_wnd_view.btn_enter_low_speed_clicked, LoadStr("POP_WND_LOWSPEED_EXIT_CANCEL"), popup_wnd_view.btn_exit_tgp_clicked);
    end;

    decode_str = function(encode_str)
        encode_str = string.gsub(encode_str, '%%(%x%x)', function(h) return string.char(tonumber(h, 16)) end);
        return encode_str;
    end;

    handel_jc_get_login_tips = function(func_name, json, browser_id)  
        base_utility.log("[popup wnd]handel_jc_get_login_tips"  ..
            ", func_name:" .. func_name ..
            ", json_str:" .. json);
        if func_name ~= "jc_get_login_tips" then 
            base_utility.log("[popup wnd][handel_jc_get_login_tips]invalid func_name"  ..
                ", func_name:" .. func_name ..
                ", json_str:" .. json, true); 
            return;
        end
        local param = base_utility.json_to_table(json);
        if nil == param then    
            base_utility.log("[popup wnd][handel_jc_get_login_tips]param is nil"  ..
                ", func_name:" .. func_name ..
                ", json_str:" .. json, true); 
                return;
        end
           
        if param.callback_func == nil or
            param.callback_func == "" then   
            base_utility.log("[popup wnd][handel_jc_get_login_tips]callback_func is empty"  ..
                ", func_name:" .. func_name ..
                ", json_str:" .. json, true); 

        end

        local rsp_table = web_utility.web_rsp_comm_data(param, 0, "");  
        if nil ~= popup_wnd_model.login_tips_ then
            rsp_table.login_tips = popup_wnd_model.login_tips_;   
        else
            rsp_table = web_utility.web_rsp_comm_data(param, -1, "");  
        end

        local rsp_json = base_utility.table_to_json(rsp_table);
        web_utility.lua_call_js_by_id_ex(param.callback_func, rsp_json, browser_id);
    end;

    -- 显示账号冻结提示框
    ShowFrozenWnd = function(nEvtID, sJson)
        if nil ~= sJson and (nil ~= TFrozenView) then
            local zParam = base_utility.json_to_table(sJson);

            if (nil ~= zParam) and (true == zParam["show"]) then
                ierd_tgp.tpf_ui.Require("popup_wnd\\frozenview.lua");
                TFrozenView.InitView();
                TFrozenView.ShowView();
                TGPLog.LogI("FrozenM", "Show frozen view.");
            else
                TFrozenView.HideView();
                TGPLog.LogI("FrozenM", "Hide frozen view.");
            end;
        else
            TGPLog.LogE("FrozenM", "Json is nil.");
        end;
    end;

    -- 提示是否启动已删除的分支
    ShowLaunchDeletedBranchPrompt = function(event_id, json_str)
        base_utility.log("[popup wnd]ShowLaunchDeletedBranchPrompt, json_str: " .. json_str);

        local info = base_utility.json_to_table(json_str);
        popup_wnd_model.set_game_icon(info.game_id);
        local ok_btn_clicked = false;

        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_LAUNCH_DELETE_BRANCH_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = "",
            tipsIcon = "",
            descTitle = "",
            desc = LoadStr("POP_WND_LAUNCH_DELETE_BRANCH_DESC"),
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_LAUNCH_DELETE_BRANCH_OK"),
                handle = function()
                    -- 切换至release分支
                    ok_btn_clicked = true;
                    popup_wnd_view:cancel_btn_clicked();

                    local game_lib = base_utility.get_component_adapter("IGame_library",
                        "ierd_tgp.game_library.Get_game_library_adapter();");
                    game_lib:SwitchToReleaseBranch(info.game_id);
                end;
            },
            cancelBtn = {
                visible = "true",
                text = LoadStr("POP_WND_LAUNCH_DELETE_BRANCH_CANCEL"),
                handle = function()
                    -- 继续启动已删除的分支
                    if not ok_btn_clicked then
                        local game_lib = base_utility.get_component_adapter("IGame_library",
                            "ierd_tgp.game_library.Get_game_library_adapter();");
                        game_lib:SetShowLaunchDeletedBranchPrompt(info.game_id, false, true);
                        game_lib:launch_game(info.game_id, 0, 0, 0, "",
                            ierd_tgp.game_library.ZONE_TYPE_FORMAL, "");
                    end;
                end,
            }
       }
       ui_utility.show_tips(param);
    end;

    -- 游戏踢下线弹框
    game_kickoff_tips = function(data)
        if nil == data or nil == data.game_id or nil == data.tip_content then
            base_utility.log("[popup_wnd_model]game_kickoff_tips, data is nil");
            return;
        end;
        local game_id = tonumber(data.game_id);
        local tip_content = data.tip_content;
        popup_wnd_model.set_game_icon(game_id);
        local param = {
            position = "center",   -- "rbottom": 右下角，"center": 居中
            title = LoadStr("POP_WND_COMMON_TITLE"),
            width = popup_wnd_constants.kPopupWidth,
            height = popup_wnd_constants.kPopupHeight,
            titleIcon = "",
            icon = popup_wnd_model.icon_url,
            tipsIcon = "",
            descTitle = tip_content,
            desc = "",
            okBtn = {
                visible = "true",
                text = LoadStr("POP_WND_COMMON_OK"),
                handle = popup_wnd_view.cancel_btn_clicked,
            },
            cancelBtn = {
                visible = "false",
                text = LoadStr("POP_WND_COMMON_CANCEL"),
                handle = function()
                end,
            }
        };
        ui_utility.show_tips(param);
    end;

    check_tips_need_show = function(tipsName, tipsHash)
        if nil == tipsName or "" == tipsName then
            return true;
        end;
        if nil == tipsHash or "" == tipsHash then
            return true;
        end;
        local data = {};
        data["common"] = 0;
        data["key"] = "app.tips."..tipsName.."."..tipsHash;
        local config = comm_center.call_service("Svr_GetConfig", data);
        if nil ~= config and 1 == config.exits then
            local cfg_tbl = base_utility.json_to_table(config.value or "{}");
            if nil ~= cfg_tbl and true == cfg_tbl.dont_ask then
                return false;
            end
        end
        return true;
    end;

    set_tips_user_disabled = function(tipsName, tipsHash)
        if nil == tipsName or "" == tipsName then
            return;
        end;
        if nil == tipsHash or "" == tipsHash then
            return;
        end;

        local config = {
            last_show_time = os.time();
            dont_ask = true
        };

        local data = {};
        data["common"] = 0;
        data["key"] = "app.tips."..tipsName.."."..tipsHash;
        data["value"] = base_utility.table_to_json(config);
        comm_center.call_service("Svr_SetConfig", data);
    end;

    on_check_should_show_poptips = function(param)
        local ret_tbl = { show = true };
        if nil == param or type(param) ~= 'table' then
            return ret_tbl;
        end
        if not popup_wnd_model.check_tips_need_show(param.name, param.hash) then
            ret_tbl.show = false;
        end
        return ret_tbl;
    end;
}

popup_wnd_model.init();
